﻿$(document).ready(function () {
    $(document).ajaxStart(function () {
        OpenLoading();
    });

    $(document).ajaxStop(function () {
        CloseLoading();
    });

    $("ul.sf-menu").supersubs({
        minWidth: 12, // minimum width of sub-menus in em units 
        maxWidth: 27, // maximum width of sub-menus in em units 
        extraWidth: 1// extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family 
    }).superfish();

});

function OpenLoading() {
    var showImage = '<p>Please wait ...</p>'
                + '<p><img src="../../Images/ajax-loader.gif" id="imgCMSLoading"><p>';

    if ($('.t-widget.t-window:first').attr('id') != undefined) {
        $.blockUI.defaults.overlayCSS.opacity = 0;
    } else {
        $.blockUI.defaults.overlayCSS.opacity = 0.5;
    }

    $.blockUI({
        message: showImage,
        css: {
            top: ($(window).height() - 200) / 2 + 'px',
            left: ($(window).width() - 200) / 2 + 'px',
            width: '200px'
        }
    });
}

function CloseLoading() {
    $.unblockUI()
}

function ValidatorUnobtrusive(divId) {
    $.validator.unobtrusive.parse(divId);
}

function GetVirtualPath(path) {
    if (AppPath != '/') {
        return AppPath + path;
    }
    else return path;
}


function onlyNumbers(evt) {
    var e = event || evt; // for trans-browser compatibility
    var charCode = e.which || e.keyCode;

    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
}